/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-06-25
 * Time: 21:32
 */
public class test5 {
    public int maxArea(int[] height) {
        int n = height.length;
        int left = 0;
        int right = n-1;
        int maxWater = Integer.MIN_VALUE;
        while(left<right){
            maxWater = Math.max(maxWater, (right-left)*Math.min(height[left],height[right]) );
            if(height[right] < height[left]){
                right--;
            }else{
                left++;
            }
        }
        return maxWater;
    }
}
